from pymysql import Connection
connection = Connection(host='localhost',
                                     port=3306,
                                     user='root',
                                     password='123456',
                                    database='test',
                                    autocommit=True)
cursor = connection.cursor()

cursor.execute("SHOW DATABASES;")
records = cursor.fetchall() #取出数据
for r in records:
     print(r)
print("---------------------")
cursor.execute("use qq;")
cursor.execute("drop table qq;")
cursor.execute("create table `qq`(qq INT, id VARCHAR(10), info VARCHAR(20));")
cursor.execute("INSERT INTO `qq` VALUES (5, 'qq', NULL)")
cursor.execute("SELECT * FROM qq;")
records = cursor.fetchall() #取出数据
for r in records:
     print(r)
cursor.close()
